<template>
  <div>
      <div class="OneList_Item" :class="{'Item_active':Itemindex===index}" @click="onClickAll(index)">所有分类</div>
      <div class="OneList_Item" :class="{'Item_active':Itemindex===index}" v-for="(item,index) in OneList" :key="index" @click="onClick(item,index)">{{item.name}}</div>
  </div>
</template>

<script>
export default {
    computed:{
        OneList:function(){
            return this.$store.state.OneList
        }
    },
    props:{
        index:Number
    },
    data(){
        return{
            Itemindex:this.index
        }
    },
    created(){
        this.$store.dispatch('CLASSIFY')
    },
    methods:{
        onClick(item,index){
            this.$store.dispatch('CLICKONE',item)
            this.Itemindex = index
        },
        onClickAll(index){
            this.$store.dispatch('CLICKONEALL')
            this.Itemindex = index
        }
    }
}
</script>

<style scoped>
.OneList_Item
{
    height: 50px;
    line-height: 50px;
    text-align: center;
    font-size: 14px;
    border: 1px solid rgba(0, 0, 0, 0.11);
}
.Item_active{
    color: red;
    border-left: 3px solid red;
}
</style>